from mercator.bd_projection import BD09Projection

import pytest


# Parametrized test for happy path with various realistic test values
@pytest.mark.parametrize("lng, lat, expected", [
    # ID: Happy-Path-1
    (12947467, 4836440, {'lng': 116.307809, 'lat': 39.987708}),
    # ID: Happy-Path-2
    (13000000, 5000000, {'lng': 116.863816, 'lat': 40.377622}),
    # ID: Happy-Path-3
    (12000000, 4000000, {'lng': 107.753901, 'lat': 34.522097}),
], ids=["Happy-Path-1", "Happy-Path-2", "Happy-Path-3"])
def test_convertMC2LL_happy_path(lng, lat, expected):
    # Act
    result = BD09Projection().pointToLngLat(lng, lat)

    # Assert
    assert result == expected


# Parametrized test for edge cases
@pytest.mark.parametrize("lng, lat, expected", [
    # ID: Edge-Case-1
    (0, 0, {'lng': 0.0, 'lat': 0.0}),
    # ID: Edge-Case-2
    (-12947474, -4836432, {'lng': -116.307872, 'lat': -39.987653}),
    # ID: Edge-Case-3
    (12947474, 0, {'lng': 12947474, 'lat': 0.0}),
    # ID: Edge-Case-4
    (0, 4836432, {'lng': 0.0, 'lat': 39.907234}),
], ids=["Edge-Case-1", "Edge-Case-2", "Edge-Case-3", "Edge-Case-4"])
def test_convertMC2LL_edge_cases(lng, lat, expected):
    # Act
    result = BD09Projection().pointToLngLat(lng, lat)

    # Assert
    assert result == expected


# Parametrized test for error cases
@pytest.mark.parametrize("lng, lat, expected", [
    (None, 4836432, {'lng': 0, 'lat': 0}),  # ID: Error-Case-1
    (12947474, None, {'lng': 0, 'lat': 0}),  # ID: Error-Case-2
    (None, None, {'lng': 0, 'lat': 0}),  # ID: Error-Case-3
    ("not-a-number", 4836432, {'lng': 0, 'lat': 0}),  # ID: Error-Case-4
    (12947474, "not-a-number", {'lng': 0, 'lat': 0}),  # ID: Error-Case-5
], ids=["Error-Case-1", "Error-Case-2", "Error-Case-3", "Error-Case-4", "Error-Case-5"])
def test_convertMC2LL_error_cases(lng, lat, expected):
    # Act
    result = BD09Projection().pointToLngLat(lng, lat)

    # Assert
    assert result == expected
